/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-05-25 16:45:02
 * @LastEditTime: 2024-06-03 20:34:59
 * @FilePath: /nest_study/src/modules/system/user/user.module.ts
 */
import { SystemUserEntity } from './entities/user.entity';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Global, Module } from '@nestjs/common';
import { UserService } from './user.service';
import { UserController } from './user.controller';
import { SystemDeptEntity } from '../dept/entities/dept.entity';
import { SystemRoleEntity } from '../role/entities/role.entity';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { SystemPostEntity } from '../post/entities/post.entity';

@Global()
@Module({
  imports: [
    TypeOrmModule.forFeature([
      SystemUserEntity,
      SystemDeptEntity,
      SystemRoleEntity,
      SystemPostEntity
    ]),
    JwtModule.registerAsync({
      imports: [ConfigModule],
      useFactory: async (config: ConfigService) => ({
        secret: config.get('jwt.secretkey'),
        signOptions: {
          expiresIn: config.get('jwt.expiresIn'),
        }
      }),
      inject: [ConfigService],
    }),
  ],
  controllers: [UserController],
  providers: [UserService],
  exports: [UserService],
})
export class UserModule { }
